//
//  ZGLIntelligenceContentCell.m
//  ZeegingLottery
//
//  Created by 蒂埃里 on 2018/10/24.
//  Copyright © 2018 蒂埃里. All rights reserved.
//

#import "ZGLIntelligenceContentCell.h"

@interface ZGLIntelligenceContentCell ()

@property (weak, nonatomic) IBOutlet UILabel *messageContentLabel;
@property (weak, nonatomic) IBOutlet UIView *colorView;


@end

@implementation ZGLIntelligenceContentCell

+ (instancetype)XibIntelligenceContentCell
{
    return [[[NSBundle mainBundle] loadNibNamed:@"ZGLIntelligenceContentCell" owner:nil options:nil]lastObject];;
    
}

- (void)setContent:(NSString *)content
{
    _content = content;
    _messageContentLabel.attributedText = [self getAttributedStringWithString:content lineSpace:3];
    
//    [self setupAutoHeightWithBottomView:self.messageContentLabel bottomMargin:0];
}

- (void)setIsHome:(BOOL)isHome
{
    if (!isHome) {
        self.colorView.backgroundColor = [UIColor blueColor];
    }
}

//内容行高
-(NSAttributedString *)getAttributedStringWithString:(NSString *)string lineSpace:(CGFloat)lineSpace {
    
    NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc] initWithString:string];
    NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc] init];
    paragraphStyle.lineSpacing = lineSpace; // 调整行间距
    NSRange range = NSMakeRange(0, [string length]);
    [attributedString addAttribute:NSParagraphStyleAttributeName value:paragraphStyle range:range];
    return attributedString;
    
    
}

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
    
    self.messageContentLabel.preferredMaxLayoutWidth = UI_SCREEN_WIDTH-52;
    
    //内容自适应
//    self.messageContentLabel.sd_layout.topEqualToView(self.contentView).leftSpaceToView(self.colorView, 8).rightSpaceToView(self.contentView, 15).bottomSpaceToView(self.contentView, 10).autoHeightRatio(0);
    
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
